package util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Md5 
{
/*Attributen*/
	private String teHashenString;

/*Constructor*/
	public Md5()
	{
	}
	public Md5(String s)
	{
		this.setTeHashenString(s);
	}
	
/*Methoden*/
	public String getMd5Hash()
	{
		MessageDigest m;
		try
		{
			String nul="";
			m = MessageDigest.getInstance("MD5");
			m.update(teHashenString.getBytes(), 0, teHashenString.length());
			String output = "" + new BigInteger(1, m.digest()).toString(16);
			for(int i=32 - output.length();i>0;i--)
				nul+="0";
			output = nul + output;
			return output;
		} catch (NoSuchAlgorithmException e)
		{
			e.printStackTrace();
		}
		return "";
	}
	public void setTeHashenString(String teHashenString)
	{
		this.teHashenString = teHashenString;
	}
}
